package com.joyoung.sweep.activity.login;


import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.joyoung.sweep.R;
import com.joyoung.sweep.activity.MainActivity;
import com.joyoung.sweep.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author: ThinkPad
 * date: 2021/4/12
 * desc: 登录
 */
public class LoginActivity extends BaseActivity {

    @BindView(R.id.bt_login)
    Button btLogin;
    @BindView(R.id.et_phone)
    EditText etPhone;
    @BindView(R.id.et_pwd)
    EditText etPwd;
    @BindView(R.id.tv_code)
    TextView tvCode;
    @BindView(R.id.et_code)
    EditText etCode;
    @BindView(R.id.code_line)
    View codeLine;
    @BindView(R.id.tv_code_send)
    TextView tvCodeSend;
    @BindView(R.id.tv_pwd_forget)
    TextView tvPwdForget;
    private boolean code = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
        code = getIntent().getBooleanExtra("code", false);
    }


    @OnClick({R.id.tv_pwd_forget, R.id.bt_login, R.id.tv_register, R.id.tv_code, R.id.iv_wx, R.id.tv_code_send})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_pwd_forget:
                openActivity(PwdForgetActivity.class);
                break;
            case R.id.bt_login:
                openAct(MainActivity.class);
                finish();
                break;
            case R.id.tv_register:
                openActivity(RegisterActivity.class);
                break;
            case R.id.tv_code:
                code = !code;
                if (!code) {
                    tvCode.setText("验证码登录");
                    tvPwdForget.setVisibility(View.VISIBLE);
                    etCode.setVisibility(View.GONE);
                    codeLine.setVisibility(View.GONE);
                    tvCodeSend.setVisibility(View.GONE);
                } else {
                    tvCode.setText("密码登录");
                    tvPwdForget.setVisibility(View.GONE);
                    etCode.setVisibility(View.VISIBLE);
                    codeLine.setVisibility(View.VISIBLE);
                    tvCodeSend.setVisibility(View.VISIBLE);
                }
                break;
            case R.id.iv_wx:
                showTip();
                break;
            case R.id.tv_code_send:
                break;
            default:
                break;
        }
    }

    private void showTip() {
        openActivity(PhoneVerificationActivity.class);
    }

}